package dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

import model.Aluno;
import model.Vaga;

public class DAOCurriculo extends ModelDAO<Vaga>{
	
	private static final EntityManagerFactory emf = Persistence.createEntityManagerFactory("escola");
	private EntityManager em;
	
	public DAOCurriculo() {
        super(Vaga.class);
    }
	
	public void save(Vaga a){
		super.begin();
		super.save(a);
		super.commit();
	}
	
	public void update(Vaga a){
		super.begin();
		super.update(a);
		super.commit();
	}
	
	public Vaga search(int cod){
		super.begin();
		Vaga a = super.search(cod);
		super.commit();
		return a;
	}
	
	public List<Vaga> listarAtivas(String sit){
		super.begin();
		String hql = "SELECT a FROM Vaga a WHERE a.situacaoVaga LIKE '%" + sit + "%'";
        Query query = em.createQuery(hql);
    	List<Vaga> list = query.getResultList();
        super.commit();
        return list;
    }
	
	public void delete(Aluno a){
		super.begin();
		super.delete(a.getCodAluno());
		super.commit();
	}

}
